<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <!--通用编辑-->
      <crudOperation :permission="permission" />
    </div>

    <!--表格渲染-->
    <el-table ref="table" v-loading="crud.loading" :data="crud.data" row-key="orgId" :tree-props="{children: 'children' ,hasChildren: 'hasChildren'}" style="width: 100%;" @select="crud.selectChange" @select-all="crud.selectAllChange" @selection-change="crud.selectionChangeHandler">
      <!--多选框-->
      <el-table-column type="selection" width="55" />
      <!--展示字段-->
      <el-table-column v-if="columns.visible('orgName')" prop="orgName" min-width="130" label="组织名称" :show-overflow-tooltip="true" />
      <el-table-column v-if="columns.visible('orgShortName')" prop="orgShortName" label="组织简称" :show-overflow-tooltip="true" />
      <el-table-column v-if="columns.visible('orgType')" prop="orgType" label="组织类型" :show-overflow-tooltip="true">
        <template slot-scope="scope">
          {{ dict.label.type_org[scope.row.orgType] }}
        </template>
      </el-table-column>
      <el-table-column v-if="columns.visible('orgCate')" prop="orgCate" label="组织类别" :show-overflow-tooltip="true">
        <template slot-scope="scope">
          {{ dict.label.type_org_cate[scope.row.orgCate] }}
        </template>
      </el-table-column>
      <el-table-column v-if="columns.visible('orgAddr')" prop="orgAddr" label="组织地址" :show-overflow-tooltip="true" />
      <el-table-column v-if="columns.visible('orgPhones')" prop="orgPhones" label="组织联系方式" :show-overflow-tooltip="true" />
      <el-table-column v-if="columns.visible('orgEmail')" prop="orgEmail" label="组织邮箱" :show-overflow-tooltip="true" />
      <el-table-column v-if="columns.visible('orgWebsite')" prop="orgWebsite" label="组织网站" :show-overflow-tooltip="true" />
      <el-table-column v-if="columns.visible('orgIntroduction')" prop="orgIntroduction" label="组织简介" :show-overflow-tooltip="true" />
      <el-table-column v-if="columns.visible('orgImgs')" prop="orgImgs" label="组织照片" :show-overflow-tooltip="true" />
      <el-table-column v-if="columns.visible('orgContacters')" prop="orgContacters" label="组织联系人" :show-overflow-tooltip="true" />
      <el-table-column v-if="columns.visible('orgLeaders')" prop="orgLeaders" label="组织负责人" :show-overflow-tooltip="true" />
      <el-table-column v-if="columns.visible('orgTags')" prop="orgTags" label="组织标签" :show-overflow-tooltip="true" />
      <el-table-column v-if="columns.visible('regionName')" prop="regionName" label="区域名称" :show-overflow-tooltip="true" />
      <el-table-column v-if="columns.visible('remark')" prop="remark" label="备注" :show-overflow-tooltip="true" />

      <!--操作-->
      <el-table-column label="操作" width="130px" align="center" fixed="right">
        <template slot-scope="scope">
          <!--通用编辑删除-->
          <udOperation :data="scope.row" :permission="permission" />
        </template>
      </el-table-column>
    </el-table>

    <!--表单渲染-->
    <editForm :dict="dict" />
  </div>
</template>

<script>
import crudDataOrg from '@/api/business/common/org/org'
import editForm from './module/editForm'
import CRUD, { presenter } from '@crud/crud'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'

// crud交由presenter持有
const crud = CRUD({ title: 'DataOrg', url: 'data/org/table/tree', crudMethod: { ...crudDataOrg }, pkIdName: 'orgId', childParamName: 'children' })

export default {
  name: 'DataOrg',
  components: { editForm, crudOperation, udOperation },
  dicts: ['type_org', 'type_org_cate'],
  mixins: [presenter(crud)],
  data() {
    return {
      // 对应几个按钮操作
      permission: {
        add: [],
        edit: [],
        del: []
      }
    }
  },
  methods: {

  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  /deep/ .el-input-number .el-input__inner {
    text-align: left;
  }
</style>
